package dailearn.producer.controller;

import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author daify
 * @date 2019-07-03 10:25
 **/
@RestController
@Log
public class ClientController {

    @Autowired DiscoveryClient discoveryClient;


    @RequestMapping(value = "getService",method = RequestMethod.GET)
    public String getService() {
        String services = "Services: " + discoveryClient.getServices();
        log.info(services);
        return services;
    }

    @RequestMapping(value = "getService",method = RequestMethod.POST)
    public String postService() {
        String services = "Services: " + discoveryClient.getServices();
        log.info(services);
        return services;
    }

    @RequestMapping(value = "test",method = RequestMethod.GET)
    public String test() {
        String services = "Services: " + discoveryClient.getServices();
        log.info(services);
        return services;
    }

    /**
     * 用来测试超时的请求
     * @param time
     * @return
     */
    @RequestMapping(value = "testParams",method = RequestMethod.POST)
    String testParams(@RequestBody Long time){
        String services = "Services: " + String.valueOf(time);
        log.info(services);
        return services;
    }
    
}
